<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div id="app">
    <h1>生命周期</h1>
    <p>{{foo}}</p>
</div>
<script src="../js/vue.js"></script>
<script>
    // 创建实例
    const app = new Vue({
        el: '#app',
        data() {
            return {
                foo: 'foo'
            }
        },
        beforeCreate() {
            console.log('beforeCreate')
        },
        created() {
            console.log('created ' + this.$el)
        },
        beforeMount() {
            console.log('beforeMount')
        },
        mounted() {
            setTimeout(() => {
                this.foo = 'foooooo'
            }, 2000)
            console.log('mounted ' + this.$el)
        },
        beforeUpdate() {
            console.log('beforeUpdate')
        },
        updated() {
            console.log('updated')
        }
    })
</script>
</body>
</html>
